import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipOutputStream;

public class precj {
  static String archive = System.getProperty("sun.boot.library.path") 
     + File.separator + ".." 
     + File.separator + "lib" 
     + File.separator + "rt.jar";
  static String newArchive = "my_rt.jar";
  static void reportClassEntryFromJar(String archive, 
		  ZipOutputStream zout, Class c) 
  {
	File jarFile = new File(archive);
	try {
		String cname = c.getName();
		String dname = cname.replaceAll("\\.", "/");
		JarFile jar = new JarFile(jarFile);		
		for (Enumeration entries = jar.entries(); 
			entries.hasMoreElements();) {
			JarEntry entry = (JarEntry) entries.nextElement();
			String name = entry.getName();
			int i = name.indexOf(".class");
			if (i>0) name = name.substring(0,i);
			int j = name.indexOf("$");
			if (j>0) name = name.substring(0,j);
			if (name.equals(dname)) {
				System.out.println(entry.getName());
				System.out.println(entry.getSize());
				System.out.println(entry.getClass());
				ZipEntry z = new ZipEntry(entry);
				zout.putNextEntry(z);
				InputStream in = jar.getInputStream(entry);
				int len=0;
				byte b[] = new byte[512];
			    while((len=in.read(b)) != -1) {
			        zout.write(b,0,len);
			    }
			    zout.closeEntry();				
			}
		}
	} catch (MalformedURLException e) {
	} catch (ZipException e) {
		System.out.println(archive);
	} catch (IOException e) {
		e.printStackTrace();
	}
  }

  public static void main(String args[]) {
	 try {
	    ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(newArchive));
	    reportClassEntryFromJar(archive, zout, String.class);
	    reportClassEntryFromJar(archive, zout, System.class);
	    reportClassEntryFromJar(archive, zout, PrintStream.class);
	    reportClassEntryFromJar(archive, zout, Object.class);
		zout.close();
	 } catch (Exception e) {
		 e.printStackTrace();
	 }
  }
}
